package com.example.day44.wm;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.Toast;

import com.example.day44.R;

public class WMActivity extends ActionBarActivity implements View.OnClickListener {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wm);
        WmHelper.init(this);
        WmHelper.getInstance().show();
//
//        manager = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
//        add();
    }


//    private void add() {
//        imageView = new ImageView(this);
//        imageView.setOnClickListener(this);
//        imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
//        imageView.setImageResource(R.mipmap.ic_launcher);
//        /**
//         * int w, 显示的宽度
//         * int h, 显示的高度
//         * int xpos,
//         * int ypos,
//         * int _type,
//         int _flags,
//         int _format
//         */
//        WindowManager.LayoutParams params = new WindowManager.LayoutParams();
//        params.width = WindowManager.LayoutParams.WRAP_CONTENT;
//        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
//        params.x = 0;
//        params.y = 0;
//        //设置弹出窗口的显示级别
//        /**
//         * type
//         * 1 WindowManager.LayoutParams.TYPE_SYSTEM_ALERT  类型与关机界面的显示级别
//         * 2 WindowManager.LayoutParams.TYPE_PHONE  类型与类似打电话界面的显示级别
//         * 3.WindowManager.LayoutParams.TYPE_PHONETYPE_APPLICATION  只能在应用程序中显示
//         */
//
//
//        params.type = WindowManager.LayoutParams.TYPE_PHONE;
//        //不优先获得焦点
//        params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
//        //设置windomanager的透明度
//        params.alpha = 1.0f;
//        manager.addView(imageView, params);
//    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        WmHelper.getInstance().remove();
    }

    @Override
    public void onClick(View v) {
        Toast.makeText(WMActivity.this, "悬浮窗口", Toast.LENGTH_SHORT).show();
    }




}
